//
//  GuideController.m
//  OnionHome
//
//  Created by fengjie on 2019/9/26.
//  Copyright © 2019 FengJie. All rights reserved.
//

#import "GuideController.h"

@interface GuideController ()
/**scrollview*/
@property (nonatomic,strong)UIScrollView*scrollview;
/**contenView*/
@property (nonatomic,strong)UIView * contenView;

@end




@implementation GuideController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self.view addSubview:self.scrollview];

    self.contenView = UIView.new;
    self.contenView.userInteractionEnabled = YES;
    [self.scrollview addSubview:self.contenView];
    
    [self.contenView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.mas_equalTo(self.scrollview);
        make.height.mas_equalTo(KScreenHeight-K_StatusBarHeight);
    }];
    
    UIImageView * oneImageView = [[UIImageView alloc] initWithImage:IMAGE_NAMED(@"guide_one")];
    UIImageView * twoImageView = [[UIImageView alloc] initWithImage:IMAGE_NAMED(@"guide_two")];
    UIImageView * thereImageView = [[UIImageView alloc] initWithImage:IMAGE_NAMED(@"guide_there")];
    UIImageView * fourImageView = [[UIImageView alloc] initWithImage:IMAGE_NAMED(@"guide_four")];
    fourImageView.userInteractionEnabled = YES;

    [self.contenView addSubview:oneImageView];
    [self.contenView addSubview:twoImageView];
    [self.contenView addSubview:thereImageView];
    [self.contenView addSubview:fourImageView];
    
    [oneImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.left.mas_equalTo(0);
        make.width.mas_equalTo(KScreenWidth);
    }];
    [twoImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.mas_equalTo(0);
        make.left.mas_equalTo(oneImageView.mas_right);
        make.width.mas_equalTo(KScreenWidth);
    }];
    [thereImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.mas_equalTo(0);
        make.left.mas_equalTo(twoImageView.mas_right);
        make.width.mas_equalTo(KScreenWidth);
    }];
    [fourImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.mas_equalTo(0);
        make.left.mas_equalTo(thereImageView.mas_right);
        make.width.mas_equalTo(KScreenWidth);
        make.right.mas_equalTo(0);
    }];
    
    UIView * view = UIView.new;
//    view.backgroundColor = KRedColor;
    [fourImageView addSubview:view];
    
    view.userInteractionEnabled = YES;
    [view addGestureRecognizer:[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapBottonViewAction)]];
    
    [view mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(55);
        make.right.mas_equalTo(-55);
        make.bottom.mas_equalTo(-45);
        make.height.mas_equalTo(50);
    }];

}
-(void)tapBottonViewAction{
    [UserModelManager setGuideType];
    if ([UserModelManager getLoginType] ) {
        kRootViewController = kAppDelegate.tabBarController;
    }else{
        kRootViewController =[[BasseNavigationController alloc] initWithRootViewController:[LoginViewController new]];
    }
}
-(UIScrollView *)scrollview{
    if (!_scrollview) {
        _scrollview =[[UIScrollView alloc] initWithFrame:CGRectMake(0, K_StatusBarHeight, KScreenWidth, KScreenHeight-K_StatusBarHeight)];
        _scrollview.alwaysBounceVertical=YES;
        _scrollview.pagingEnabled = YES;
        _scrollview.showsVerticalScrollIndicator = NO;
        _scrollview.showsHorizontalScrollIndicator = NO;
//        _scrollview.contentSize = CGSizeMake(4*KScreenWidth, KScreenHeight-K_StatusBarHeight);
        _scrollview.bounces = NO;
    }
    return _scrollview;
}
@end
